package com.dyzx.hbb.modules.wms.controller;


import com.dyzx.hbb.common.config.MyLambdaQueryWrapper;
import com.dyzx.hbb.common.controller.BaseValidController;
import com.dyzx.hbb.modules.wms.entity.WmsStockTakesDetails;
import com.dyzx.hbb.modules.wms.query.WmsStockTakesDetailsQuery;
import com.dyzx.hbb.modules.wms.service.WmsStockTakesDetailsService;
import com.dyzx.hbb.modules.wms.vo.WmsStockTakesDetailsUVO;
import com.dyzx.hbb.modules.wms.vo.WmsStockTakesDetailsVO;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 库存调拨明细管理控制器
 * <p>处理仓库管理系统中库存调拨明细的创建、查询和管理业务逻辑
 * <p>主要职责：
 * <ul>
 * <li>提供库存调拨明细的基础CRUD操作</li>
 * <li>支持按调拨单ID、库存ID、货位ID、区域ID、仓库ID和状态等条件筛选明细信息</li>
 * <li>维护库存调拨明细数据的排序展示</li>
 * </ul>
 * <p>设计意图：为仓库管理模块提供库存调拨明细的数据管理接口，
 * 确保库存调拨业务的可追踪性和明细数据的准确性
 * 
 * @author 开发团队
 * @version 1.0.0
 * @since 2023-05-30
 */
@Tag(name = "库存调拨明细管理", description = "库存调拨明细相关接口")
@RestController
@RequestMapping("/wms/stock/takes/details")
public class WmsStockTakesDetailsController extends BaseValidController<
        WmsStockTakesDetailsService,
        WmsStockTakesDetails,
        WmsStockTakesDetailsQuery,
        WmsStockTakesDetailsVO,
        WmsStockTakesDetailsUVO
        > {

    @Autowired
    private WmsStockTakesDetailsService service;

    @Override
    protected WmsStockTakesDetailsService getBaseService() {
        return service;
    }

    @Override
    protected MyLambdaQueryWrapper<WmsStockTakesDetails> queryWrapper(WmsStockTakesDetailsQuery query) {
        MyLambdaQueryWrapper<WmsStockTakesDetails> queryWrapper = new MyLambdaQueryWrapper<>();
        queryWrapper.orderByDesc(WmsStockTakesDetails::getCreateDate);

        if (query != null) {
            queryWrapper.eq(query.getTake_id() != null, WmsStockTakesDetails::getTakeId, query.getTake_id())
                    .eq(query.getInventory_id() != null, WmsStockTakesDetails::getInventoryId, query.getInventory_id())
                    .eq(query.getLocation_id() != null, WmsStockTakesDetails::getLocationId, query.getLocation_id())
                    .eq(query.getLocation_area_id() != null, WmsStockTakesDetails::getLocationAreaId, query.getLocation_area_id())
                    .eq(query.getHouse_id() != null, WmsStockTakesDetails::getHouseId, query.getHouse_id())
                    .eq(query.getStatus() != null, WmsStockTakesDetails::getStatus, query.getStatus());
        }
        return queryWrapper;
    }

    @Override
    protected MyLambdaQueryWrapper<WmsStockTakesDetails> queryInfoWrapper() {
        MyLambdaQueryWrapper<WmsStockTakesDetails> queryWrapper = new MyLambdaQueryWrapper<>();
        queryWrapper.orderByDesc(WmsStockTakesDetails::getCreateDate);
        return queryWrapper;
    }

    @Override
    protected WmsStockTakesDetails addValid(WmsStockTakesDetailsVO entity) {
        return null;
    }

    @Override
    protected WmsStockTakesDetails editValid(WmsStockTakesDetailsUVO entity) {
        return null;
    }
}